package cn.edu.zut.cs.controller;

import cn.edu.zut.cs.pojo.User;
import cn.edu.zut.cs.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@ResponseBody
public class RegisterController {
    @Resource
    private UserService userService;

    //注册功能
    @RequestMapping("/registertion")
    @ResponseBody
    public String registertion(String username,String userpassword,String reuserpassword, Model model){

//        QueryWrapper<User> wrapper=new QueryWrapper<>();
//        wrapper.eq("username",username);
//        User user = userService.getOne(wrapper);
//        if(user==null){
//            if(userpassword.equals(reuserpassword)){
//                user.setUsername(username);
//                user.setUserpassword(userpassword);
//                userService.save(user);
//                model.addAttribute("msg","注册成功，请重新登录");
//                return "redirect:/index";
//            }else{
//                model.addAttribute("msg","两次密码输入不一样，请重新注册");
//                return "register";
//            }
//
//        }else{
//            model.addAttribute("msg","该用户名已经存在，请重新注册");
//            return "register";
//        }

        return "404";
    }


}
